# -*- Mode: makefile -*-
#
# ppc64 specific tweaks

VPATH += $(SRC_PATH)/tests/tcg/ppc64

config-cc.mak: Makefile
	$(quiet-@)( \
	    $(call cc-option,-mcpu=power8,      CROSS_CC_HAS_CPU_POWER8); \
	    $(call cc-option,-mpower10,         CROSS_CC_HAS_POWER10)) 3> config-cc.mak

-include config-cc.mak

# multi-threaded tests are known to fail (e.g., clang-user CI job)
# See: https://gitlab.com/qemu-project/qemu/-/issues/2456
run-signals: signals
	$(call skip-test, $<, "BROKEN (flaky with clang) ")
run-plugin-signals-with-%:
	$(call skip-test, $<, "BROKEN (flaky with clang) ")

run-threadcount: threadcount
	$(call skip-test, $<, "BROKEN (flaky with clang) ")
run-plugin-threadcount-with-%:
	$(call skip-test, $<, "BROKEN (flaky with clang) ")

ifneq ($(CROSS_CC_HAS_CPU_POWER8),)
PPC64_TESTS=bcdsub non_signalling_xscv
endif
$(PPC64_TESTS): CFLAGS += -mcpu=power8

ifneq ($(CROSS_CC_HAS_CPU_POWER8),)
PPC64_TESTS += vsx_f2i_nan
endif
vsx_f2i_nan: CFLAGS += -mcpu=power8 -I$(SRC_PATH)/include

PPC64_TESTS += mtfsf
PPC64_TESTS += mffsce

ifneq ($(CROSS_CC_HAS_POWER10),)
PPC64_TESTS += byte_reverse sha512-vector vector
endif
byte_reverse: CFLAGS += -mcpu=power10
run-byte_reverse: QEMU_OPTS+=-cpu POWER10

sha512-vector: CFLAGS +=-mcpu=power10 -O3
sha512-vector: sha512.c
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)

run-sha512-vector: QEMU_OPTS+=-cpu POWER10

vector: CFLAGS += -mcpu=power10 -I$(SRC_PATH)/include
run-vector: QEMU_OPTS += -cpu POWER10

PPC64_TESTS += signal_save_restore_xer
PPC64_TESTS += xxspltw
PPC64_TESTS += test-aes

# ppc64 ABI uses function descriptors, and thus, QEMU can't find symbol for a
# given instruction. Thus, we don't check output of mem-access plugin.
run-plugin-test-plugin-mem-access-with-libmem.so: \
 CHECK_PLUGIN_OUTPUT_COMMAND=

TESTS += $(PPC64_TESTS)
